﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BuildPlannerLib.SimEvents
{
    // Derived class from Event for a worker returning minerals
    public class ReturnMinerals : SimEvent
    {
        // Field for the base at which mining is taking place
        public Base AtBase;

        // Field for the per-trip yield of the mineral patch
        public int Yield;

        // Basic Constructor with parameters for the parent build, mineral yield and time
        public ReturnMinerals(Build build, Base b, int yield, int time)
        {
            Build = build;
            AtBase = b;
            Yield = yield;
            Time = time;
        }

        // Adds minerals from the return and adds an event for the worker reaching close mineral patches
        public override void Execute()
        {
            Build.Player.Minerals.Change(Yield);
            
            int newTime = Time;
            AtBase.MineralWorkerStatus[0]++;
            newTime += 186;
            Build.EventList.Add(new ReachCloseMinerals(Build, AtBase, newTime));
        }
    }
}
